package com.llmcu.graphic.designpatterns.interpreter;

import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class RepeatCommandNode extends CommandNode {
    public static final String REPEAT_TOKEN = "repeat";

    private CommandListNode commandListNode;
    private int count;

    @Override
    public void parse(Context context) {
        context.skip(REPEAT_TOKEN);
        count = Integer.parseInt(context.getCurrentToken());
        context.nextToken();

        commandListNode = new CommandListNode();
        commandListNode.parse(context);

    }

    @Override
    public String toString() {
        return "[repeat" + count + commandListNode +
                ']';
    }
}
